<template>
  <div>
    <h5>当前最新的count值为:{{ $store.state.count }}</h5>
    <h5>{{ $store.getters.showNum }}</h5>
    <button @click="handleAdd">+3</button>
    <button @click="handleAddAsync">+3 async</button>
  </div>
</template>
<script>
export default {
  data () {
    return {}
  },
  methods: {
    handleAdd () {
      this.$store.commit('add', 3)
    },
    // 异步加1
    handleAddAsync () {
      // 这里的dispatch函数专门用来触发action
      this.$store.dispatch('addAsync', 3)
    }
  }
}
</script>
